webpackJsonp([22],{

/***/ "/X1a":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/regenerator/index.js
var regenerator = __webpack_require__("lC5x");
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__("J0Oq");
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/helpers/extends.js
var helpers_extends = __webpack_require__("4YfN");
var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);

// EXTERNAL MODULE: ./src/apps/analysis/danger-source-check-topic.gql
var danger_source_check_topic = __webpack_require__("9FOO");
var danger_source_check_topic_default = /*#__PURE__*/__webpack_require__.n(danger_source_check_topic);

// EXTERNAL MODULE: ./src/common/api/commonApi.js
var commonApi = __webpack_require__("+/+p");

// EXTERNAL MODULE: ./node_modules/_lodash@4.17.11@lodash/lodash.js
var lodash = __webpack_require__("psq8");
var lodash_default = /*#__PURE__*/__webpack_require__.n(lodash);

// EXTERNAL MODULE: ./node_modules/_echarts@3.8.5@echarts/lib/echarts.js
var echarts = __webpack_require__("+Ky8");
var echarts_default = /*#__PURE__*/__webpack_require__.n(echarts);

// EXTERNAL MODULE: ./node_modules/_echarts@3.8.5@echarts/theme/macarons.js
var macarons = __webpack_require__("TW58");
var macarons_default = /*#__PURE__*/__webpack_require__.n(macarons);

// EXTERNAL MODULE: ./node_modules/_echarts@3.8.5@echarts/lib/chart/line.js
var line = __webpack_require__("feM/");
var line_default = /*#__PURE__*/__webpack_require__.n(line);

// EXTERNAL MODULE: ./node_modules/_echarts@3.8.5@echarts/lib/chart/pie.js
var pie = __webpack_require__("bGGv");
var pie_default = /*#__PURE__*/__webpack_require__.n(pie);

// CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@13.7.3@vue-loader/lib/selector.js?type=script&index=0!./src/apps/analysis/danger-source-check-topic.vue



//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//









var COLORS = ['#ff0001', '#66ff00', '#669800', '#003299', '#ffff00', '#69fdff', '#66339a', '#ff9900', '#797878'];
var LEVELS = ['一级风险', '二级风险', '三级风险', '四级风险'];

/* harmony default export */ var analysis_danger_source_check_topic = ({
  data: function data() {
    var _this = this;

    var grid = { name: 'XXX', enterprises: [], total: 0 };
    return {
      search: false,
      selected: [],
      entList: [],
      rightData: [{
        font: 'yt-icon yt-icon-search',
        click: function click() {
          _this.search = !_this.search;
        }
      }],
      disasterDic: [],
      grid: [grid, grid, grid, grid, grid],
      currentId: null,
      LEVELS: LEVELS,
      total: ['N/A', 'N/A', 'N/A', 'N/A'],
      chartLineObj: null,
      chartPieObj: null,
      colors: COLORS,
      chartLineOption: {
        grid: {
          left: '20%'
        },
        tooltip: {
          trigger: 'axis'
        },
        xAxis: [{
          name: '重大危险源/个数',
          nameLocation: 'center',
          nameGap: '30',
          type: 'value'
        }],
        yAxis: [{
          name: '事故类型',
          nameLocation: 'end',
          boundaryGap: true,
          type: 'category',
          data: []
        }],
        series: [{
          name: '政府',
          type: 'bar',
          data: []
        }]
      },
      chartPieOption: {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          x: 'right',
          y: 'top',
          data: LEVELS
        },
        series: [{
          name: '访问来源',
          type: 'pie',
          radius: ['50%', '70%'],
          center: ['40%', '50%'],
          label: {
            normal: {
              show: false
            }
          },
          data: [{ value: 335, name: '一级风险' }, { value: 310, name: '二级风险' }, { value: 234, name: '三级风险' }, { value: 234, name: '四级风险' }]
        }]
      }
    };
  },
  activated: function activated() {
    this.chartLineObj = echarts_default.a.init(this.$refs.chartLine, 'macarons');
    this.chartPieObj = echarts_default.a.init(this.$refs.chartPie, 'macarons');
    this.onInit();
  },

  methods: {
    renderTotal: function renderTotal(total) {
      var obj = lodash_default.a.zipObject(total.keys, total.values);
      this.grid = this.grid.map(function (item) {
        var total = item.enterprises.reduce(function (total, v) {
          return total + (obj[v.id] || 0);
        }, 0);
        return extends_default()({}, item, { total: total });
      });
    },
    renderCard1: function renderCard1(total) {
      this.chartPieOption.series[0].data = total.values.map(function (item, index) {
        return { value: item, name: LEVELS[index] };
      });
      this.chartPieObj.setOption(this.chartPieOption);
    },
    renderCard2: function renderCard2(genre) {
      var data = this.disasterDic.map(function (item) {
        var index = genre.keys.indexOf(item.D_code);
        return {
          name: item.D_text,
          value: index > -1 ? genre.values[index] : 0
        };
      });
      this.chartLineOption.yAxis[0].data = this.disasterDic.map(function (v) {
        return v.D_text;
      });
      this.chartLineOption.series[0].data = data;
      this.chartLineObj.setOption(this.chartLineOption);
    },
    getGql: function getGql(id) {
      var param = { ascending: 'level' };
      return commonApi["a" /* commonApi */].gql(danger_source_check_topic_default.a, {
        'qjson': id ? lodash_default.a.merge(param, { equalTo: ['unit', id] }) : param
      });
    },
    onSearch: function onSearch(id) {
      var _this2 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee() {
        var _ref, total, level, genre;

        return regenerator_default.a.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                _this2.search = false;
                _this2.currentId = id;
                _context.next = 4;
                return commonApi["a" /* commonApi */].dictionary('disaster');

              case 4:
                _this2.disasterDic = _context.sent;
                _context.next = 7;
                return _this2.getGql(id);

              case 7:
                _ref = _context.sent;
                total = _ref.total;
                level = _ref.level;
                genre = _ref.genre;

                _this2.renderTotal(total);
                _this2.renderCard1(level);
                _this2.renderCard2(genre);

              case 14:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, _this2);
      }))();
    },
    onInit: function onInit() {
      var _this3 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2() {
        return regenerator_default.a.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                _context2.next = 2;
                return commonApi["a" /* commonApi */].search('sys_grid', { equalTo: { gridLevel: 2 } });

              case 2:
                _this3.grid = _context2.sent;
                _context2.next = 5;
                return commonApi["a" /* commonApi */].search('ent_enterprise');

              case 5:
                _this3.entList = _context2.sent;

                _this3.onSearch();

              case 7:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, _this3);
      }))();
    }
  }
});
// CONCATENATED MODULE: ./node_modules/_vue-loader@13.7.3@vue-loader/lib/template-compiler?{"id":"data-v-5ac3fc42","hasScoped":false,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/_vue-loader@13.7.3@vue-loader/lib/selector.js?type=template&index=0!./src/apps/analysis/danger-source-check-topic.vue
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('yt-page',{attrs:{"title":"重大危险源报警统计","scroll":"","rightData":_vm.rightData}},[_c('yt-card',{attrs:{"title":"评估登记占比统计"}},[_c('div',{ref:"chartPie",staticStyle:{"width":"100%","height":"300px"}})]),_vm._v(" "),_c('yt-card',{attrs:{"title":"重大危险源事故类型统计柱图"}},[_c('div',{ref:"chartLine",staticStyle:{"height":"800px"}})]),_vm._v(" "),_c('yt-popup',{attrs:{"slot":"alert","pos":"right","mask":true},slot:"alert",model:{value:(_vm.search),callback:function ($$v) {_vm.search=$$v},expression:"search"}},[_c('yt-page',{staticClass:"page",attrs:{"flex":true,"leftData":[],"title":"企业列表"}},[_c('yt-form',{staticStyle:{"background-color":"#fff"}},[_c('yt-radioList',{staticClass:"list",attrs:{"list":_vm.entList,"label":"EnterpriseName","val":"id","inline":false},model:{value:(_vm.selected),callback:function ($$v) {_vm.selected=$$v},expression:"selected"}}),_vm._v(" "),_c('yt-btn-group',{attrs:{"slot":"btn","shadow":false},slot:"btn"},[_c('yt-btn',{attrs:{"theme":"white"},on:{"click":function($event){_vm.search = false}}},[_vm._v("关闭")]),_vm._v(" "),_c('yt-btn',{on:{"click":function($event){return _vm.onSearch(_vm.selected)}}},[_vm._v("确定")])],1)],1)],1)],1)],1)}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ var apps_analysis_danger_source_check_topic = (esExports);
// CONCATENATED MODULE: ./src/apps/analysis/danger-source-check-topic.vue
var normalizeComponent = __webpack_require__("C7Lr")
/* script */


/* template */

/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = null
/* scopeId */
var __vue_scopeId__ = null
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
  analysis_danger_source_check_topic,
  apps_analysis_danger_source_check_topic,
  __vue_template_functional__,
  __vue_styles__,
  __vue_scopeId__,
  __vue_module_identifier__
)

/* harmony default export */ var src_apps_analysis_danger_source_check_topic = __webpack_exports__["default"] = (Component.exports);


/***/ }),

/***/ "9FOO":
/***/ (function(module, exports) {

module.exports = "query fetch($qjson: JSON) {\n  total: security_risk_filingAggregate(qjson: $qjson) @_(get: \"groupedBy.unit\") {\n    groupedBy {\n      unit {\n        keys\n        values @_(map: \"count\") {\n          count\n        }\n      }\n    }\n  }\n  level: security_risk_filingAggregate(qjson: $qjson) @_(get: \"groupedBy.level\") {\n    groupedBy {\n      level {\n        keys\n        values @_(map: \"count\") {\n          count\n        }\n      }\n    }\n  }\n  genre: security_risk_filingAggregate(qjson: $qjson) @_(get: \"groupedBy.genre\") {\n    groupedBy {\n      genre {\n        keys\n        values @_(map: \"count\") {\n          count\n        }\n      }\n    }\n  }\n}"

/***/ })

});